angular 2 location.go vs window.location.href
全部标签 在index.html中,我添加了来自https://mixpanel.com/help/reference/javascript的混合面板代码.在我的exportclassMixpanelService{constructor(){mixpanel.init("sdfsdf",'',"development");}publictrack(){mixpanel.track('click',{pageName:'login'})}}出现以下错误:Cannotfindname'mixpanel'.mixpanel.init("sdfsdf",'',"development");谁能帮我解决
我正在Angular2中实现需要使用setTimeout的功能。我的代码:publicngAfterViewInit():void{this.authenticate_loop();}privateauthenticate_loop() {setTimeout(()=>{console.log("HellofromsetTimeout");},500)}setTimeout由ngAfterViewInit启动,但循环只执行一次,例如。“HellofromsetTimeout”只打印一次。问题:如何更改代码以使setTimeout起作用? 最佳答案
在我的应用程序中,我有一个按钮,甚至可以点击它:在doSomething方法中,有没有办法从按钮中删除(click)事件(这样用户就不能再触发功能了?).我试图在按钮上设置一个禁用的属性,但它不会改变Angular2的行为。我尝试使用(click)="doSomething($event)然后doSomething($event){//Mymethodlogicgoeshere......console.log('MethodLogic');//Attempttooverwriteclickeventlettarget=event.target||event.srcElement||e
我有一个简单的对象数组,想获取第一个元素的位置属性:constcompanies=[{name:'Google',location:'MountainView'},{name:'Facebook',location:'MenloPark'},{name:'Uber',location:'SanFrancisco'}];const[{location}]=companies;//expected:MountainViewbutgotUncaughtSyntaxError:Identifier//'location'hasalreadybeendeclaredat:1:1我错过了什么?
如何动态设置今天的最大日期而不是2018-03-07?我尝试了以下方法-类-publictoday=newDate();但没有运气。 最佳答案 试试这个:today=newDate().toJSON().split('T')[0];WorkingExampleDemoReason:因为当您使用newDate()时,这将为您提供包含时区和时间等的完整日期,您必须仅分配日期,因此您必须仅将其与日期分开。如需更多说明,请运行此命令:console.log(newDate(),'----',newDate().toJSON());
我有一个Angular应用程序,我想在其中使用particles.js,但是我不知道如何添加它并让它工作。我已经将它添加到.angular-cli.json"scripts":["../node_modules/particles.js/particles.js"],我已经将它导入到我的组件中import*asparticlesJSfrom'particles.js';并尝试使用初始化它particlesJS.load('particles-js','assets/particles.json',function(){console.log('callback-particles.js
我想动态更改输入占位符的文本。console.log已经给出了更新后的字符串,但界面没有更新,所以旧的占位符仍然存在。如何让界面识别更改?document.getElementById(this.implicKey).setAttribute('placeholder',options[i].implication);console.log(document.getElementById(this.implicKey).getAttribute('placeholder')); 最佳答案 您可以像这样动态更改您的输入占位符Thisf
我正在使用ajax更新框架中页面的位置。但是当设置散列的位置时(特别是在Chrome和某些版本的IE(5.5)上,但偶尔在IE7上)页面正在重新加载。下面的html演示了这个问题。主框架....frame.html是sethash.html页面是.varCount=0;functionsethash(){top.document.location.hash="hash"+Count;Count++;}Hello`在大多数浏览器上加载frame.html将在页面加载时显示一次加载警报。然后当按下设置哈希按钮时,url将被更改,但加载的警报的哈希将不会再次显示。在chrome和某些版本的I
我有3个点(纬度、经度)组成一个三Angular形。如何确定一个点是否在这个三Angular形内? 最佳答案 只有三Angular形的Java代码,即3个点。publicstaticbooleanpntInTriangle(doublepx,doublepy,doublex1,doubley1,doublex2,doubley2,doublex3,doubley3){doubleo1=getOrientationResult(x1,y1,x2,y2,px,py);doubleo2=getOrientationResult(x2,y2
我有代码片段,它是在点击如下链接时执行的cj_redirecturl="/HomeWork/main/load_course";utility.xhttprw.data(cj_redirecturl,{data:courseid},function(response){if(response){window.location.href=base_url+"main";///nextutility.xhttprw.data(redirecturl,{data:""},function(response){if(response){id=ent;document.getElementByI